package org.example;

import java.time.LocalTime;

public class TimeTask implements Runnable {
    private final int seconds;

    public TimeTask(int seconds) {
        this.seconds = seconds;
    }

    @Override
    public void run() {
        for (int i = 0; i < seconds; i++) {
            System.out.println("当前时间: " + LocalTime.now());
            try {
                Thread.sleep(1000); // 暂停 1 秒
            } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
            }
        }
        System.out.println("任务完成 ✅");
    }
}
